<form action="{:sysuri()}" data-table-id="FormTable" class="layui-form layui-card" data-auto="true" method="post">
    <div class="layui-card-body padding-left-40">
        <div class="layui-form-item relative block">
            <span class="help-label"><b>属性名称</b>Attr Name</span>
            <label class="relative block">
                <input name='attr_name' required placeholder="请输入类型名称" value='{$vo.attr_name|default=""}' class="layui-input">
            </label>
            <span class="help-block"><b>必填，</b>请填写属性名称。</span>
        </div>
        <div class="layui-form-item layui-row layui-col-space15">
            <div class="layui-col-xs6 relative block">
                <span class="help-label"><b>属性类型</b>Attr Type</span>
                <label class="relative block">
                    <!-- {foreach ['0'=>'单选属性','1'=>'多选属性','2'=>'唯一属性'] as $k=>$v} -->
                        <!--{if (!isset($vo.attr_type) and $k eq '0') or (isset($vo.attr_type) and $vo.attr_type eq $k)}-->
                        <label class="think-radio"><input checked lay-ignore name="attr_type" type="radio" value="{$k}"> {$v}</label>
                        <!--{else}-->
                            <label class="think-radio"><input lay-ignore name="attr_type" type="radio" value="{$k}"> {$v}</label>
                        <!--{/if}-->
                    <!-- {/foreach} -->
                </label>
            </div>
            <div class="layui-col-xs3 relative block">
                <span class="help-label"><b>属性是否必填</b>Attr Choose</span>
                <label class="relative block">
                    <!-- {foreach ['0'=>'是','1'=>'否'] as $k=>$v} -->
                        <!--{if (!isset($vo.is_choose) and $k eq '0') or (isset($vo.is_choose) and $vo.is_choose eq $k)}-->
                            <label class="think-radio"><input checked lay-ignore name="is_choose" type="radio" value="{$k}"> {$v}</label>
                        <!--{else}-->
                            <label class="think-radio"><input lay-ignore name="is_choose" type="radio" value="{$k}"> {$v}</label>
                        <!--{/if}-->
                    <!-- {/foreach} -->
                </label>
            </div>
            <div class="layui-col-xs3 relative block">
                <span class="help-label"><b>属性多选上限</b>Attr Choose Max</span>
                <label class="relative block">
                    <select name="attr_smax">
                        <!-- {foreach ['1','2','3','4','5'] as $k=>$v} -->
                        <!--{if (isset($vo.attr_smax) and $vo.attr_smax eq $v)}-->
                            <option selected value="{$v}">{$v}</option>
                        <!--{else}-->
                            <option value="{$v}">{$v}</option>
                        <!--{/if}-->
                        <!-- {/foreach} -->
                    </select>
                </label>
            </div>
        </div>
        <div class="layui-form-item relative block">
            <span class="help-label"><b>属性录入方式</b>Attr Input Name</span>
            <label class="relative block">
                <!-- {foreach ['0'=>'手工录入','1'=>'从下面的列表中选择(普通属性值以","号隔开)','2'=>'从下面列表中选择(多维属性以";"隔开)'] as $k=>$v} -->
                    <!--{if (!isset($vo.attr_input_type) and $k eq '0') or (isset($vo.attr_input_type) and $vo.attr_input_type eq $k)}-->
                    <label class="think-radio"><input checked lay-ignore name="attr_input_type" type="radio" value="{$k}"> {$v}</label>
                    <!--{else}-->
                        <label class="think-radio"><input lay-ignore name="attr_input_type" type="radio" value="{$k}"> {$v}</label>
                    <!--{/if}-->
                <!-- {/foreach} -->
            </label>
        </div>
        <div class="layui-form-item relative block">
            <span class="help-label"><b>属性值</b>Attr Desc</span>
            <label class="relative block">
                <!-- {if !isset($vo.attr_input_type) || $vo.attr_input_type eq '0'} -->
                    <textarea class="layui-textarea layui-disabled" disabled placeholder="请输入属性值,每个属性值以','号隔开。" name="attr_value">{$vo.attr_value|default=''}</textarea>
                <!-- {else} -->
                    <textarea class="layui-textarea" placeholder="请输入属性值,每个属性值以','号隔开。" name="attr_value">{$vo.attr_value|default=''}</textarea>
                <!-- {/if} -->
            </label>
            <span class="help-textarea help-block">手动创建属性规格。</span>
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}
    <input type='hidden' value='{$vo.type_id|default=input("type_id")}' name='type_id'>
    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" data-close type='button' data-confirm="确定要取消编辑吗？">取消编辑</button>
    </div>
</form>
<script>
    $(document).ready(function() { 
        $('input[type=radio][name=attr_input_type]').change(function() {
            if (this.value == '0') {
                $('.layui-textarea').addClass('layui-disabled');
                $('.layui-textarea').attr('disabled', true);
                $('.help-textarea').html('手动创建属性规格。');
            } else if (this.value == '1') {
                $('.layui-textarea').removeClass('layui-disabled');
                $('.layui-textarea').attr('disabled', false);
                $('.help-textarea').html('普通规格属性以","隔开；如:"A,B,C,D,..."。');
            } else if (this.value == '2') {
                $('.layui-textarea').removeClass('layui-disabled');
                $('.layui-textarea').attr('disabled', false);
                $('.help-textarea').html('多维规格属性以";"隔开；如:"A,[A1,A2,A3..];B,[B1,B2,B3...]"。');
            } 
        }); 
    });
</script>